package com.pocket.demo.base.consts;

import org.apache.commons.lang3.StringUtils;

/**
 * @author zhaozhile
 */
public class SecurityConst {
    public static final String ROLE_PREFIX = "ROLE_";
    public static final String SCOPE_PREFIX = "SCOPE_";

    public static final String ROLE_NONE = "none";
    public static final String ROLE_ADMIN = "admin";

    public static final String SYSTEM_USER_LIST = "system:user:list";
    public static final String SYSTEM_USER_ADD = "system:user:add";
    public static final String SYSTEM_USER_EDIT = "system:user:edit";
    public static final String SYSTEM_USER_REMOVE = "system:user:remove";

    public static String getSecurityRole(String role) {
        if (StringUtils.isBlank(role) || role.startsWith(ROLE_PREFIX)){
            return role;
        }
        return ROLE_PREFIX + role;
    }
}
